package interfaces.spawnMenu.costumize.hunters;

import org.fenggui.binding.render.ImageFont;
import org.fenggui.decorator.background.PlainBackground;
import org.fenggui.event.IButtonPressedListener;
import org.fenggui.util.Color;

import logic.common.team.Fraction;
import logic.nodes.lod.BBNodeController;
import logic.ships.hunter.Hunter;
import interfaces.ImageUpdater;
import interfaces.superWidgets.InterfaceButton;
import interfaces.superWidgets.StaticContent;

public class HunterButton extends StaticContent {
	
	private InterfaceButton button;
	private ImageUpdater image;
	private String hunterName;
	
	public HunterButton(int width, int height, Hunter hunter, Fraction fraction, ImageFont buttonFont, Color bgColor) {
		super(width, height);
		this.hunterName = hunter.getName();
		
		int border = height / 10;
		
		int imageSize = height - (2 * border);
		String imagePath = "data/fractions/" + fraction.toString().toLowerCase() + "/ships/" + hunterName + BBNodeController.ICON_FILE;
		
		image = new ImageUpdater(imagePath, border, border, imageSize, imageSize);
		addWidget(image);
		
		button = new InterfaceButton(hunter.getHunterName(), buttonFont);
		button.setSize(width - imageSize - (2 * border), height - (2 * border));
		button.setXY(imageSize + border, border);
		addWidget(button);
		
		getAppearance().add(new PlainBackground(bgColor));
		
		layout();
	}
	
	public String getHunterName() { return hunterName; }
	
	public void addButtonListener(IButtonPressedListener listener) {
		button.addButtonPressedListener(listener);
	}
}